package intermediate_representation;

import symbal.Vtype;

import java.util.ArrayList;

public class CallRP extends InterRP {
    private ArrayList<String> paras;
    private String returns;
    private String name;

    public CallRP(String returns, String name) {
        this.returns = returns;
        this.name = name;
        this.paras = new ArrayList<>();
    }

    public CallRP(String name) {
        this.name = name;
        this.paras = new ArrayList<>();
    }

    public void setResult(String name) {
        this.returns = name;
    }

    public void addPara(String para) {
        paras.add(para);
    }

    public ArrayList<String> getParas() {
        return paras;
    }

    public String getReturns() {
        return returns;
    }

    public String getName() {
        return name;
    }

    public String toString() {
        String str = "";
        for (String para: paras) {
            str += "push " + para + "\n";
        }
        str += "call " + name;
        if (returns != null) {
            str += "\n" + returns + " = RET";
        }
        return str;
    }
}
